const express = require('express');
const path = require('path');
const cookieParser = require('cookie-parser');
const logger = require('morgan');
const adminAuth = require('./midwares/auth')
require('dotenv').config()
const indexRouter = require('./routes/index');
const usersRouter = require('./routes/users');
const articleRouter = require('./routes/admin/article')
const authRouter = require('./routes/admin/auth')
const likeRouter = require('./routes/like')
const app = express();


app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));

app.use('/',indexRouter);
app.use('/users',adminAuth, usersRouter);
app.use('/admin/article', adminAuth,articleRouter)
app.use('/admin/auth', authRouter) // 登录相关的不能加

app.use('/like', adminAuth, likeRouter)
module.exports = app;
